/* eslint-disable class-methods-use-this */
import {
  post,
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Room {
  async getRoomList(page, limit, info) {
    const res = await get(`v1/room?page=${page}&limit=${limit}`, info)
    return res
  }

  async getRoomOrderList(page, limit, info) {
    const res = await get(`v1/room_order?page=${page}&limit=${limit}`, info)
    return res
  }

  async getRoomInfo(id) {
    const res = await get(`v1/room/${id}`)
    return res
  }

  async createRoom(info) {
    const res = await post('v1/room', info)
    return res
  }

  async updateRoom(info) {
    const res = await put('v1/room', info)
    return res
  }

  async updateRoomOne(info) {
    const res = await put('v1/room_recommend', info)
    return res
  }

  async deleteRoom(id) {
    const res = await _delete(`v1/room/${id}`)
    return res
  }

  async RoomOrderCheck(info) {
    const res = await put('v1/room_order/check', info)
    return res
  }

  async RoomOrderSend(info) {
    const res = await put('v1/room_order/send', info)
    return res
  }

  async RoomOrderSendOne(info) {
    const res = await put('v1/room_order/send-one', info)
    return res
  }
}

export default new Room()
